<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page import = "com.broadvision.portal.foundation.action.microsite.participant.ParticipantBaseAction" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>

<bean:define id="micrositeNaviInfoParams" name="micrositeNaviInfoView" property="urlParams" scope="request" />


<%
 java.util.Map urlParamsMap = (java.util.Map)pageContext.getAttribute("micrositeNaviInfoParams");
 Long displayPhaseId = (Long)urlParamsMap.get("displayPhaseId");
 String currentAction = (String)urlParamsMap.get("currentAction");
 String delimiter = ParticipantBaseAction.DELIMITER;
%>
<script language="JavaScript">

function validateForm(theForm) {
  //
  // check at least one participant is designated as a owner.
  //
  var len = theForm.ownerIds.length;

  if (len) { //more than 1.
    for ( var i=0; i<len; i++ ) {
      if (theForm.ownerIds[i].checked == true) {
        return true;
      }
    }
  } else {
    if (theForm.ownerIds.checked == true) {
      return true;
    }
  }

  //There is no one checked.
  alert('<bean:message key="cs.error.one.participant.owner"/>');
  return false;
}

function confirmDelete() {
  if ( confirm('<bean:message key="cs.confirm.delete.participant"/>') ){
    return true;
  } else {
    return false;
  }
}        

function confirmDeleteGroup() {
  if ( confirm('<bean:message key="cs.confirm.delete.group.participant"/>') ){
    return true;
  } else {
    return false;
  }
}        

//
// Create a dummy (timestamp) attribute to get around an IE cache problem.
//
function getTimeStamp() {
   var now = new Date;
   var timestamp = '' + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds() + now.getMilliseconds();
   return timestamp;
}   

var win;
var popupURL = '<html:rewrite page="/cs/participantFind.do" name="micrositeNaviInfoParams" />';
function findUserPopup() {
  var timestamp = getTimeStamp();
  win = window.open(popupURL + '&timestamp=' + timestamp, "SelectParticipants" , "width=700,height=600,scrollbars=yes,resizable=yes");
  if ( win != null) {
    if( win.opener == null) {
      win.opener = self;
    }
  }
  win.focus();
}

var groupPopupURL = '<html:rewrite page="/cs/participantFindGroup.do" name="micrositeNaviInfoParams" />';
function findGroupPopup() {
  var timestamp = getTimeStamp();
  win = window.open(groupPopupURL + '&timestamp=' + timestamp, "SelectGroupParticipants" , "width=700,height=600,scrollbars=yes,resizable=yes");
  if ( win != null) {
    if( win.opener == null) {
      win.opener = self;
    }
  }
  win.focus();
}

var refreshURL = '<html:rewrite page="/cs/participantListUpdate.do" name="micrositeNaviInfoParams" />';

function refreshParticipants(userList) {
  if ( userList.length <= 0 )
    return;

  var participantList = "" ;
  participantList = '&newParticipants=' + userList.join("<%=delimiter%>");

  window.location = refreshURL + participantList+'&displayPhaseId=<%=displayPhaseId%>&currentAction=<%=currentAction%>';
  if ( win != null ) {
    win.focus();
  }
}

var refreshGroupURL = '<html:rewrite page="/cs/participantListUpdateGroup.do" name="micrositeNaviInfoParams" />';

function refreshGroupParticipants(groupList) {
  if ( groupList.length <= 0 )
    return;

  var participantList = "" ;
  participantList = '&newParticipants=' + groupList.join("<%=delimiter%>");

  window.location = refreshGroupURL + participantList+'&displayPhaseId=<%=displayPhaseId%>&currentAction=<%=currentAction%>';
  if ( win != null ) {
    win.focus();
  }
}

function onClickNotify(theForm) {
  theForm.action = '<html:rewrite page="/cs/participantNotify.do" />';
  theForm.submit();
}

</script>

<!-- BEGIN form ( csParticipantListForm ) -->
<html:form action="/cs/participantListSave.do">
<bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>

<!-- Zone 5 starts here.  -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
         summary="content area">
  <tr>
    <td valign="top">
    
    <div class="pageTitle">
      <%@ include file="/cs/microsite/micrositeNaviInfo.jsp" %>
    </div> 
    
    <!--end page title area here-->
    <div class="pageSubtitle">
      <span class="left">
        <bean:message key="cs.participant.user.list.title"/>
      </span>
      <span class="right">
      <logic:equal name="participantListView" property="displayNotifyButton" value="true">
        <input type="button" class="titleButton" name="notifyBtn"
             titleKey="button.notify" 
             value='<bean:message key="button.notify"/>'
             onclick="onClickNotify(this.form)">&nbsp;
      </logic:equal>
        <html:button property="findUser" onclick="findUserPopup()" styleClass="titleButton">
          <bean:message key="cs.button.findMoreUserParticipants"/>
        </html:button>
      </span>
    </div> 

    <!--end title bar here-->
    
    <div class="blockWrap">
    <!-- Start List here -->
    <table class="dataTable" border="0" cellspacing="1" cellpadding="0" 
           summary="User participant list table" width="100%">
      <tr class="listHeader"> 
        <th id="FullName" align="left"><bean:message key="cs.name"/></th>
        <th id="UserName" align="left"><bean:message key="cs.login"/></th>
        <th id="IsOwner" align="center"><bean:message key="cs.owner"/></th>
        <th id="IsContact" align="center"><bean:message key="cs.participant.contact"/></th>
        <th id="Action" align="left"><bean:message key="cs.actions"/></th>
      </tr>
    

      <logic:iterate id="oneParticipant" name="participantListView" property="participantList" indexId="index">
        <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
          <td headers="FullName" align="left">
            <bean:write name="oneParticipant" property="fullName" />
          </td>
          <td headers="UserName" align="left">
            <bean:write name="oneParticipant" property="userAlias" />
          </td>
          <td headers="IsOwner" align="center">
            <html:multibox name="csParticipantListForm" property="ownerIds"> 
              <bean:write name="oneParticipant" property="userId" />
            </html:multibox>
          </td>

          <td headers="IsContact" align="center">
            <html:multibox name="csParticipantListForm" property="contactIds">
              <bean:write name="oneParticipant" property="userId" />
            </html:multibox>
          </td>
  
          <td headers="Action" align="left">&nbsp;
            <%-- Display edit button --%>
            <html:link page="/cs/participantEdit.do" name="oneParticipant" property="urlParams">
              <html:img page="/cs/images/action/icon_edit.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.edit"/>
            </html:link>

            <%-- Display delete button --%>
            <logic:notEqual name="oneParticipant" property="isCurrentVisitor" value="true">
              <html:link page="/cs/participantListDelete.do" name="oneParticipant" property="urlParams" onclick="return confirmDelete();">
                <html:img page="/cs/images/action/icon_delete.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.delete"/>
              </html:link>
            </logic:notEqual>
          </td>
        </tr> 
      </logic:iterate>    
    </table> 
    </div>
    
   
    
    <!-- End participants list -->
    <logic:equal name="participantListView" property="showGroupParticipantList" value="true"> 
	  <div class="pageSubtitle">
        <span class="left">
          <bean:message key="cs.participant.group.list.title"/>
        </span>
        <span class="right">
          <html:button property="findGroup" onclick="findGroupPopup()" styleClass="titleButton">
            <bean:message key="cs.button.findMoreGroupParticipants"/>
          </html:button>
        </span>
      </div> 

			<div class="blockWrap">
	  <!-- Start Groups List here -->
      <table class="dataTable" border="0" cellspacing="1" cellpadding="0" 
           summary="Group participant list table" width="100%">
        <tr class="listHeader"> 
          <th id="FullName" align="left"><bean:message key="cs.name"/></th>
          <th id="Action" align="left"><bean:message key="cs.actions"/></th>
        </tr>
        <logic:iterate id="oneGroup" name="participantListView" property="groupParticipantList" indexId="index">
	      <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
            <td headers="FullName" align="left">
              <bean:write name="oneGroup" property="fullName" />
            </td>
            <td headers="Action" align="left">&nbsp;
              <%-- Display delete button --%>
              <html:link page="/cs/participantListDeleteGroup.do" name="oneGroup" property="urlParams" onclick="return confirmDeleteGroup();">
                <html:img page="/cs/images/action/icon_remove.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.remove"/>
              </html:link>
            </td>
          </tr> 
        </logic:iterate>
      </table>
    </logic:equal>
	<!-- End groups list -->

    <!--start reset, save bar area here-->

    <div class="pageButtonWrap" align="right">
      <html:reset styleClass="pageButton" property="resetBtn" titleKey="button.reset">
        <bean:message key="button.reset"/>
      </html:reset>           
      &nbsp;&nbsp;
      <html:submit styleClass="pageButton" property="saveBtn" 
              titleKey="button.save" onclick="return validateForm(this.form)">
        <bean:message key="button.save" />
      </html:submit>
    </div>
    <!--end cancel, reset, save bar area here-->   
    </td>
  </tr>
</table>
</div>
</html:form>

<!-- END form ( csParticipantListForm ) -->
